﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 递归练习_汉诺塔
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("请输入所需移动的盘子数量");
            int n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("移动{0}个盘子的步骤如下：", n);
            Move(n, "A", "B", "C");
            Console.ReadKey();
        }
        static void Move(int n, string a, string b, string c)
        {
            if (n == 1)
                Console.WriteLine("将盘子{0}从{1}移动到{2}", n, a, c);
            else
            {
                Move(n - 1, a, c, b);
                //将n号盘子从a柱移动到c柱
                Console.WriteLine("将盘子{0}从{1}移动到{2}", n, a, c);
                //用本方法剩余n-1个盘子从b柱经由a柱移动到c柱
                Move(n - 1, b, a, c);
            }
        }
    }
}
